import java.util.*;


public class text1 {
    public static boolean Find(int target, int [][] array) {
        Scanner a=new Scanner(System.in);
        if(array.length==0)
        {
            return false;
        }
        int n=array[0].length;
        int m=array.length;
        int i=0;


          in:
        for(i=0;i<m;i++)
        {
            if(array[i][n-1]>target)
            {
                int j=0;
                for(j=0;j<n-1;j++)
                {
                    if(array[i][j]==target)
                    {
                        return true;
                    }
                }
            }
            else if(array[i][n-1]<target)
            {
                break in;
            }
            else
            {
                return true;
            }

        }


            return false;






}






    public static void main(String[] args) {
        int target=15;
        int[][]f={{1,2,8,9},{2,4,9,12},{4,7,10,13},{6,8,11,15}};
        Find(target,f);


    }


}
